package com.qf.mvc.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.Map;

@Controller
@RequestMapping("/cap")
@ResponseBody
public class KapcharController {
    @RequestMapping("/login")
    public Map<String, String> login(String username, String password, String cap, HttpSession session) {
        String captcha = (String) session.getAttribute("captcha");
        System.out.println(captcha);
        Map<String,String> map=new HashMap<>();
        if (!captcha.equals(cap)) {
            map.put("code","1");
            map.put("msg","登陆成功");
        }else {
            map.put("code","-1");
            map.put("msg","登陆失败");
        }
        return map;
    }
}
